<template>
	<view>
		<view class="search" @click="toSearch">
			<icon type="search" color="white" size="10"></icon>
			<input type="text" value="" placeholder="搜索商品" placeholder-class="placeholder"  />
		</view>
		<view class="list">
			<view class="row" v-for="(item,index) in list" :key="item.id" @click="toDetail(item.id)">
				<image :src="baseUrl+item.img" mode="widthFix"></image>
				<view class="info">
					<text>{{item.goodsname}}</text>	
					<text>￥{{item.price}}</text>	
					<text>{{item.market_price}}评论</text>	
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {baseUrl} from "../../utils/config.js"
	export default{
		data(){
			return{
				list:[],
				baseUrl:baseUrl
			}
		},
		async onLoad(e){
			// console.log(e);
			var fid = e.id
			// console.log(fid);
			var result = await this.http("/api/getcategoods",{fid}).catch(err=>{
				console.log(err);
			})
			// console.log(result,"---------");
			this.list = result.data.list
		},
		methods:{
			toDetail(id){
			uni.navigateTo({
				url:"/pages/details/details?id="+id
				})
			},
			toSearch(){
				uni.navigateTo({
					url:"/pages/search/search"
				})
			}
	}
		
}
	
</script>

<style>
	.search{
		margin: 50rpx;
		height: 80rpx;
		background-color: #f26b11;
		border-radius: 80rpx;
		color: white;
		display: flex;
		justify-content: center;
		align-items: center;
	}
	icon{
		margin:0 10rpx 0 250rpx;
	}
	.placeholder{
		color: white;
		font-size: 25rpx;
	}
	.row{
		position: relative;
		margin: 10rpx 20rpx;
		height: 330rpx;
		border-bottom: 1rpx solid #AAAAAA;
	}
	image{
		position: absolute;
		top: 0;
		left:10rpx;
		width: 160rpx;
	}
	.info{
		height: 85%;
		width: 100%;
		position: absolute;
		top: 0;
		left: 200rpx;
		display: flex;
		justify-content: space-around;
		flex-direction: column;
		font-size: 25rpx;
	}
	.info text:nth-of-type(2){
		color: red;
	}
	.info text:nth-of-type(3){
		font-size: 20rpx;
		color: #AAAAAA;
	}
	.tishi{
		line-height: 200rpx;
		text-align: center;
		font-size: 40rpx;
		color: #006699;
	}
</style>
